package com.eastedu.repository.question.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eastedu.repository.question.po.QuestionAssociationPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 袁松明
 */
@Mapper
@DS("question")
public interface QuestionAssociationMapper extends BaseMapper<QuestionAssociationPO> {
    /**
     * 删除知识点
     *
     * @param questionId 试题ID
     */
    @Update("DELETE FROM t_question_association WHERE question_id = #{questionId} AND `type` = 1")
    void deleteAllByQuestionId(@Param("questionId") Long questionId);

    /**
     * 删除知识点
     *
     * @param questionId 试题ID
     */
    @Select("SELECT * FROM t_question_association WHERE question_id = #{questionId} AND `type` = 1")
    List<QuestionAssociationPO> findAllByQuestionId(@Param("questionId") Long questionId);
}
